<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="UTF-8">
    <title>路由</title>
    <script src="../vue.js"></script>
    <script src="../vue-router.js"></script>
</head>

<body>
    <div id="app">
       
    </div>
    <script>
        const Notfound = {template:'<p>没找到</p>'};
        const Home = {template:'<p>主页</p>'};
        const about = {template:'<p>关于</p>'}
        const routes= {
            '/':Home,
            'about':about
        }
        var app = new Vue({
            el: '#app',
            data() {
                return {
                    currentRoute:window.location.pathname
                }
            },
            computed:{
                ViewComponent :function(){
                    return routes[this.currentRoute] || Notfound
                }
            },
            render(h){return h(this.ViewComponent)}
          
        })
    </script>
</body>

</html>